# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/25 上午11:50
 @Author  : tgy
 
"""
from Node import Node


def copyRandomList(head:Node) -> Node:
    ...
    copy_node_map = {}
    node = head
    # 复制所有Node节点
    while node:
        copy_node_map[node] = Node(node.val)
        node = node.next

    dummyNode = Node(0)
    tailNode = dummyNode

    node = head
    while node:
        ...
        tailNode.next = copy_node_map.get(node)
        tailNode = tailNode.next
        if node.random:
            tailNode.random = copy_node_map.get(node.random)
        node = node.next
    return dummyNode.next



if __name__ == '__main__':
    ...
